<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>

	</body>
	<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
	<script type="text/javascript">
		//实际上就是新建一个iframe的生成器
		var createIframe = (function() {
			var iframe;
			return function() {
				if(iframe) {
					return iframe;
				} else {
					iframe = document.createElement('iframe');
					iframe.style.display = 'none';
					document.body.appendChild(iframe);
					return iframe;
				}
			}
		})()

		//生成一个url scheme,假设我们约定的scheme是myApp://type=1&id=iewo212j32这种形式的

		var baseScheme = "myApp://"
		var createScheme = function(options) {
			var urlScheme = baseScheme;
			for(var item in options) {
				urlScheme = urlScheme + item + '=' + encodeURIComponent(options[item]) + "&";
			}
			urlScheme = urlScheme.substring(0, urlScheme.length - 1);
			return encodeURIComponent(urlScheme);
		}

		var openApp = function() {
			var localUrl = createScheme();
			var openIframe = createIframe();
			if(isIos()) {
				//判断是否是ios,具体的判断函数自行百度
				window.location.href = localUrl;
				var loadDateTime = Date.now();
				setTimeout(function() {
					var timeOutDateTime = Date.now();
					if(timeOutDateTime - loadDateTime < 1000) {
						window.location.href = "你的下载页面";
					}
				}, 25);
			} else if(isAndroid()) {
				//判断是否是android，具体的判断函数自行百度
				if(isChrome()) {
					//chrome浏览器用iframe打不开得直接去打开，算一个坑
					window.location.href = localUrl;
				} else {
					//抛出你的scheme
					openIframe.src = localUrl;
				}
				setTimeout(function() {
					window.location.href = "你的下载页面";
				}, 500);
			} else {
				//主要是给winphone的用户准备的,实际都没测过，现在winphone不好找啊
				openIframe.src = localUrl;
				setTimeout(function() {
					window.location.href = "你的下载页面";
				}, 500);
			}
		}
	</script>

</html>